package com.wmada.toolkit.common.secure;

/**
 * @author will.ma
 * @date 2017/3/11
 */
public class MD5Utils {

    private static final String DIGEST_ALGORITHM    = "MD5";
    private static final String SIGNATURE_ALGORITHM = "HmacMD5";

    public static String getDigest(String message) {
        Digest digest = new Digest(DIGEST_ALGORITHM);
        return digest.getDigest(message);
    }

    public static byte[] getDigest(byte[] data) {
        Digest digest = new Digest(DIGEST_ALGORITHM);
        return digest.getDigest(data);
    }

    public static String getSignature(String message, String key) {
        Signature signature = new Signature(SIGNATURE_ALGORITHM, key);
        return signature.getSignature(message);
    }

    public static byte[] getSignature(byte[] data, String key) {
        Signature signature = new Signature(SIGNATURE_ALGORITHM, key);
        return signature.getSignature(data);
    }

}
